package com.gdcn.zb.sys.service.impl;

import java.util.List;

import com.gdcn.zb.base.BaseService;
import com.gdcn.zb.base.exception.DaoException;
import com.gdcn.zb.base.exception.ServiceException;
import com.gdcn.zb.sys.dao.ISummaryDao;
import com.gdcn.zb.sys.service.ISummaryService;
import com.gdcn.zb.sys.valueobject.Summary;

public class SummaryServiceImpl extends BaseService implements ISummaryService {
	private ISummaryDao summaryDao ; 
	
	public void setSummaryDao(ISummaryDao summaryDao) {
		this.summaryDao = summaryDao;
	}

	public void createSummary(Summary summary) throws ServiceException {
		try{
			summaryDao.createSummary(summary);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public void deleteSummary(int id) throws ServiceException {
		try{
			summaryDao.deleteSummary(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public Summary findSummaryById(int id) throws ServiceException {
		Summary summary = null;
		try{
			summary = summaryDao.findSummaryById(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return summary;
	}

	public List<Summary> findSummaryBySummaryName(String summaryName)throws ServiceException {
		// TODO Auto-generated method stub
		return null;
	}

	public void updateSummary(Summary summary)throws ServiceException {
		try{
			summaryDao.updateSummary(summary);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public List<Summary> listSummaryByUser(String userId) {
		List<Summary> list = null;
		try{
			list = summaryDao.listSummaryByUser(userId);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return list;
	}

	public void deleteSummary(String[] id) throws ServiceException {
		if(id != null){
			for(int i=0;i<id.length;i++){
				deleteSummary(Integer.parseInt(id[i]));
			}
		}
		
	}

}
